messages = """
MIN

USER
DISCONNECTED

LOGIN
LOGOUT

BATTLE_CREATE
BATTLE_TICK
BATTLE_OVER

BATTLE_INSTRUCT

MAX
"""

battle_instructs = """
MESSAGE

CREATE_UNIT
REMOVE_UNIT

FREE_CLICK

ACTION_TIME
COOLDOWN_TIME
STIFF_TIME

FIRE
HURT
CURE

MAX
"""

def message():
    mm = messages.split()
    mc = list(zip(range(10, 10 + len(mm) + 1, 1), mm))

    def p(m):
        print(m)
        print(m, file=f)

    f = open('../src/main/java/game/leon/war/defs/MessageConsts.java', 'w')
    p('package game.leon.war.defs;')
    p('public interface MessageConsts {')
    for n, m in mc:
        p('int {0} = {1};'.format(m.upper(), n))
    p('}')
    f.close()

    f = open('MessageConsts.cs', 'w')
    p('namespace warfour {')
    p('public class MessageConsts {')
    for n, m in mc:
        p('public const int {0} = {1};'.format(m.upper(), n))
    p('}}')
    f.close()

def battle_instruct():
    mm = battle_instructs.split()
    mc = list(zip(range(1, 1 + len(mm) + 1, 1), mm))

    def p(m):
        print(m)
        print(m, file=f)
        

    f = open('../src/main/java/game/leon/war/defs/InstructConsts.java', 'w')
    p('package game.leon.war.defs;')
    p('public interface InstructConsts {')
    for n, m in mc:
        p('int {0} = {1};'.format(m.upper(), n))
    p('}')
    f.close()
	
    f = open('InstructConsts.cs', 'w')
    p('namespace warfour {')
    p('public class InstructConsts {')
    for n, m in mc:
        p('public const int {0} = {1};'.format(m.upper(), n))
    p('}}')
    f.close()

def main():
    message()
    battle_instruct()

if __name__ == '__main__':
    main()
